package 考试.Question14;

import java.text.ParseException;
import java.util.Date;

public class TestDateUtils {
    public static void main(String[] args) {
        try {
            // 测试Date转String
            System.out.println("=== 测试Date转String ===");
            Date currentDate = new Date();
            String dateString = DateUtils.dateToString(currentDate);
            System.out.println("当前时间: " + currentDate);
            System.out.println("转换后字符串: " + dateString);

            // 测试String转Date
            System.out.println("\n=== 测试String转Date ===");
            String testString = "2026-01-22 00:00:00";
            Date testDate = DateUtils.stringToDate(testString);
            System.out.println("原始字符串: " + testString);
            System.out.println("转换后Date: " + testDate);


            
        } catch (ParseException e) {
            System.err.println("日期解析错误: " + e.getMessage());
        }
    }
}












































/*
// 测试反向转换
            System.out.println("\n=== 测试反向转换 ===");
String backToString = DateUtils.dateToString(testDate);
            System.out.println("再次转换为字符串: " + backToString);

// 测试null值处理
            System.out.println("\n=== 测试null值处理 ===");
String nullString = DateUtils.dateToString(null);
            System.out.println("Date为null时转换结果: " + nullString);*/
